package com.zly.bscloud.controller;

import com.zly.bscloud.dto.OrderdetailDTO;
import com.zly.bscloud.entity.Orderdetail;
import com.zly.bscloud.service.OrderdetailService;
import com.zly.bscloud.utils.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zhouxiaoyu
 * @Date 2020/5/27 0:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/orderdetail")
@CrossOrigin
public class OrderdetailController {
    @Autowired
    public OrderdetailService orderdetailService;

    @PostMapping("/save-orderdetail")
    public Result saveOrderdetail(@RequestBody Orderdetail orderdetail){

        Orderdetail orderdetailnew=orderdetailService.saveOrderdetail(orderdetail);

        return Result.createSuccess(orderdetailnew);
    }

    @GetMapping("/get-orderdetail/{order_id}")
    public Result getOrderdetail(@PathVariable("order_id") String order_id){
        //System.out.println("1"+order_id);
        List<OrderdetailDTO> ordersdetailDTOList = orderdetailService.getOrderdetail(order_id);
        //System.out.println("2"+ordersdetailDTOList);
        return Result.createSuccess(ordersdetailDTOList);
    }
}
